﻿
@{
    ViewBag.Title = "CarQueryIndex";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function() {
        gridList();
    });
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Project/GudaoCar/GetGridJsonCar",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "F_Id", hidden: true, key: true },
                {
                    label: '车号', name: 'BelongCarriage', width: 50, align: 'left',
                    formatter: function (cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue.CarriageID: "未填写";
                    }
                },
                {
                    label: '股道', name: 'BelongPathway', width: 50, align: 'left',
                    formatter: function (cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue.Name: "未填写";
                    }
                },
                {
                    label: '车型', name: 'BelongCarriage', width: 50, align: 'left',
                    formatter: function (cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue.CarType : "未填写";
                    }
                },
                {
                    label: '载重(吨)', name: 'BelongCarriage', width: 50, align: 'left',
                    formatter: function (cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue.Capacity : "未填写";
                    }
                },
                {
                    label: '品名', name: 'ThingsName', width: 50, align: 'left'
                },
                {
                    label: '封号', name: 'Fenhao', width: 70, align: 'left'
                },
                {
                    label: '到站', name: 'ArriveStation', width: 80, align: 'left'
                },
                {
                    label: '件数', name: 'UnitNumber', width: 40, align: 'left',
                    formatter: function (cellvalue) {
                        return cellvalue == null ? "0" :cellvalue;
                    }

                },
                {
                    label: '重量(吨)', name: 'Weight', width: 50, align: 'left',
                    formatter: function (cellvalue) {
                        return cellvalue == null ? "0" :cellvalue;
                    }
                },
                {
                    label: '客户', name: 'Customers', width: 60, align: 'left',
                    formatter: function (cellvalue) {
                        return cellvalue == null ? "未填写" : cellvalue;
                    }
                },
                {
                    label: '是否起票', name: 'isQiPiao', width: 65, align: 'left',
                    formatter: function (cellvalue) {
                        //return cellvalue != null ? Date(cellvalue).toLocaleString() : "未起票";
                        return cellvalue == true ? "已起票" : "未起票";
                    }
                    //formatter: "date", formatoptions: { srcformat: 'Y-m-d h:i:s', newformat: 'Y-m-d' }
                },
                {
                    label: '是否统计运量', name: 'isAccomplishStatistics', width: 80, align: 'left',
                    formatter: function (cellvalue) {
                        // cellvalue != null ? Date(cellvalue).toLocaleString() : "未统计";
                        return cellvalue == true ? "已统计" : "未统计";
                    }
                },
                {
                    label: '是否放行', name: 'IsAccomplishPermitThrough', width: 65, align: 'left',
                    formatter: function (cellvalue) {
                        return cellvalue == true ? "已放行" : "未放行";
                       // return cellvalue != null ? Date(cellvalue).toLocaleString() : "未放行";
                    }
                },
                {
                    label: '是否对位', name: 'IsAccomplishduiwei', width: 65, align: 'left',
                    formatter: function (cellvalue) {
                        //return cellvalue != null ? Date(cellvalue).toLocaleString() : "未对位";
                        return cellvalue == true ? "已对位" : "未对位";
                    }
                },
                {
                    label: '到达时间', name: 'ArriveDateTime', width: 135, align: 'left'
                    //formatter: "date", formatoptions: { srcformat: 'Y-m-d h:i:s', newformat: 'Y-m-d  h:i:s' }
                },
                {
                    label: '备注', name: 'Remark', width: 100, align: 'left'
                }
            ],
            pager: "#gridPager",
            sortname: 'ArriveDateTime desc',
            viewrecords: true

        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: {
                    gudaoName: $("#txt_keyword").val(),
                    carId: $("#carId").val()
                }
            }).trigger('reloadGrid');
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "添加股道",
            url: "/Project/Pathway/Form",
            width: "650px",
            height: "650px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: "Form",
            title: "修改股道信息",
            url: "/Project/Pathway/Form?keyValue=" + keyValue,
            width: "650px",
            height: "650px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {

        $.deleteForm({
            url: "/Project/Pathway/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().F_Id },
            success: function() {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: "Details",
            title: "查看股道详情",
            url: "/Project/Pathway/Details?keyValue=" + keyValue,
            width: "1000px",
            height: "720px",
            btn: null
        });
    }

</script>


<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            @*<a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新增股道</a>*@
        </div>
        @*<div class="operate">*@
            @*<ul class="nav nav-pills">*@
                @*<li class="first">已选中<span>1</span>项</li>*@
                @*<li><a id="NF-edit" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改股道</a></li>
                <li><a id="NF-delete" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除股道</a></li>*@
                @*<li><a id="NF-Details" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看详情</a></li>*@
                @*<li class="split"></li>*@
            @*</ul>*@
            @*<a href="javascript:;" class="close"></a>*@
        @*</div>*@
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group" style="padding-left:11px;padding-right:10px;">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="按照股道名模糊搜索" style="width: 200px; margin-right:20px;">
                        <input id="carId" type="text" class="form-control" placeholder="按照车号模糊搜索" style="width: 200px; margin-right:20px;">
                        @*<input id="txt_name" type="text" class="form-control" placeholder="按照场主名称模糊搜索" style="width: 200px; margin-right:20px;">*@
                            <span class="input-group-btn">
                                <button id="btn_search" type="button" class="btn  btn-primary active"><i class="fa fa-search"></i></button>
                            </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<style>
    table tr td {
        padding-left: 15px;
    }
</style>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>



